/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.garcomeletronico.dao.implementacao;

import br.com.garcomeletronico.utils.Conexao;
import java.sql.Connection;
import java.sql.SQLException;

/**
 *
 * @author Rivi
 */
public abstract class DAOGenerico {
    
    private Connection connection;
    
    private Conexao classeConexao;
    
    public DAOGenerico() {
        if (classeConexao == null) {
            classeConexao = new Conexao();
        }
    }
    
    protected Connection getConexao() throws SQLException {
        if (connection == null) {
            connection = classeConexao.getConexao();
        }
        return connection;
    }
    
    protected void finalize() throws Throwable {
        super.finalize();
        classeConexao.fecharConexao();
}
    
}
